// const baseUrl = "http://60.210.40.218:8899/"
// const baseUrl = "http://cppcc.shx1024.top:39005/"
const baseUrl = "http://192.168.0.131:48080/"
// const baseUrl = "http://192.168.2.104:39003/"
const request = (url = '', date = {}, type = 'POST', header = {
	'content-type': 'application/x-www-form-urlencoded'
}) => {
	return new Promise((resolve, reject) => {
		uni.request({
			method: type,
			url: baseUrl + url,
			data: date,
			header: header,
			dataType: 'json',
		}).then((response) => {
			let [error, res] = response;
			if (res.data.code == 0) {
				uni.showToast({
					title: res.data.msg,
					icon: "none",
					duration: 2000
				});
			}
			if (res.data.code == 401) {
				uni.reLaunch({
					url: '../login/index'
				})
			}

			resolve(res.data);
		}).catch(error => {
			let [err, res] = error;
			reject(err)
		})
	});
}
export default request